package com.shen.pojo.draw;

/**
 * Author:shen
 * CreateDate:2020/5/13.
 * Function:
 */
public class Triangle implements Graphics{
    private double a;
    private double b;
    private double c;

    public Triangle() {
    }

    public Triangle(double a, double b, double c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }

    public double getA() {
        return a;
    }

    public void setA(double a) {
        this.a = a;
    }

    public double getB() {
        return b;
    }

    public void setB(double b) {
        this.b = b;
    }

    public double getC() {
        return c;
    }

    public void setC(double c) {
        this.c = c;
    }

    private boolean isTriangle(){
            boolean isflag=false;
            if(a>=b&&a>=c){
                isflag=a<(b+c)? true:false;
            }
            if(b>=a&&b>=c){
                isflag=b<(a+c)? true:false;
            }
            if(c>=a&&c>=b){
                isflag=a<(a+b)? true:false;
            }
            return isflag;
    }

    @Override
    public double perimeter() {
       return isTriangle()? (a+b+c):-1;
    }

    @Override
    public double area() {
        double p=perimeter();
        return isTriangle() ? Math.sqrt(p*(p-a)*(p-b)*(p-c)):-1;
    }
}
